package main

import (
	"fmt"
	"go-web-learning/src/02_message_system/02_message_system/chatroom/client/processes"
)

func main() {
	// 接收用户的选择
	var key int
	// 判断是否还要继续显示菜单
	var loop = true
	for loop {
		fmt.Println("\t\t\t欢迎登陆多人聊天室\t\t\t")
		fmt.Println("\t\t\t\t1 登陆")
		fmt.Println("\t\t\t\t2 注册")
		fmt.Println("\t\t\t\t3 退出")
		fmt.Println("\t\t\t\t 请选择(1-3):")

		fmt.Scanf("%d\n", &key)
		switch key {
		case 1:
			fmt.Println("登陆聊天室")
			var userId int
			var userPwd string
			fmt.Println("请输入账号:")
			fmt.Scanf("%d\n", &userId)
			fmt.Println("请输入密码:")
			fmt.Scanf("%s\n", &userPwd)
			up := processes.UserProcess{}
			err := up.Login(userId, userPwd)
			if err != nil {
				return
			}
		case 2:
			fmt.Println("注册用户")
			var userId int
			var userPwd string
			var userName string
			fmt.Println("请输入账号:")
			fmt.Scanf("%d\n", &userId)
			fmt.Println("请输入密码:")
			fmt.Scanf("%s\n", &userPwd)
			fmt.Println("请输入昵称:")
			fmt.Scanf("%s\n", &userName)
			up := processes.UserProcess{}
			err := up.Register(userId, userPwd, userName)
			if err != nil {
				return
			}
		case 3:
			fmt.Println("退出成功")
			loop = false
		default:
			fmt.Println("您的输入有误，请重新输入")
		}
	}
}

func registerUi() {
	fmt.Println("注册！")
}
